<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
	<xsl:output method="xml" version="1.0" encoding="utf-8" omit-xml-declaration="yes" indent="yes"/>
	<xsl:strip-space elements="*"/>
	<xsl:param name="mode" />
	<xsl:param name="action" />
	<xsl:param name="xml" />
	<xsl:param name="referer" />
	
	<xsl:template match="/">
		<xsl:choose>
			<xsl:when test="$mode = 'cms'">
				<ul id="tree_view">
					<li class="root">
					<span><xsl:comment> </xsl:comment></span>
					<a id="rootLink" href="/home/" fullpath="/" path="/" title="Accueil" class="pager">Accueil</a>
					<ul>
						<xsl:apply-templates select="child::node()" mode="cms"/>
					</ul>
				</li>
			</ul>		
			</xsl:when>
			<xsl:when test="$mode = 'form'">
				<xsl:apply-templates select="child::node()" mode="form"/>
			</xsl:when>
			<xsl:when test="$mode = 'list'">
				<ul>
					<xsl:apply-templates select="child::node()" mode="list"/>
				</ul>
			</xsl:when>
			<xsl:when test="$mode = 'select'">
				<form method="post" action="/action/modifPage.php">
					<xsl:apply-templates select="child::node()" mode="select"/>
					<input type="hidden" name="xmlUrl" value="{$xml}" />
					<input type="hidden" name="referer" value="{$referer}" />
					<input type="hidden" name="action" value="{$action}" />
					<input type="submit" value="Choisir" />
				</form>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates select="child::node()" mode="list"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	
	
	<!-- MODE CMS -->
	<xsl:template match="file" mode="cms">
		<li class="file inactive">
			<i><xsl:comment> </xsl:comment></i>
			<span><xsl:comment> </xsl:comment></span>
			<a 
				href="/page{@fullpath}"
				fullpath="{@fullpath}"
				path="{@path}"
				title="{@fullpath}"
				rel="/pages/{@page_uid_id}.xml"
				class="pager pagerNoCache">
				<xsl:value-of select="./@breadcrumbName" />
			</a>
		</li>
	</xsl:template>
	
	<xsl:template match="folder" mode="cms">
		<li class="folder">
			<span class="cursor"><xsl:comment> cursor </xsl:comment></span>
			<span><xsl:comment> selector</xsl:comment></span>
			<a 
				href="/folder{@fullpath}"
				fullpath="{@fullpath}"
				path="{@path}"
				title="{@fullpath}"
				rel="/application/edito/xml{@page_uid_id}.xml"
				class="pager">
				<xsl:value-of select="./@breadcrumbName" />
			</a>
			<xsl:if test="count(child::node()) &gt; 0">
				<ul>
					<xsl:apply-templates select="child::node()" mode="cms"/>
				</ul>
			</xsl:if>
		</li>
	</xsl:template>
	
	
	
	
	
	<!-- MODE LIST -->
	<xsl:template match="file" mode="list">
		<li class="file inactive">
			<a 
				href="/page{@fullpath}"
				fullpath="{@fullpath}"
				path="{@path}"
				title="{@fullpath}"
				rel="/pages/{@page_uid_id}.xml"
				class="pager pagerNoCache">
				<xsl:value-of select="./@breadcrumbName" />
			</a>
		</li>
	</xsl:template>
	
	<xsl:template match="folder" mode="list">
		<li class="folder">
			<a 
				href="/folder{@fullpath}"
				fullpath="{@fullpath}"
				path="{@path}"
				title="{@fullpath}"
				rel="/application/edito/xml{@page_uid_id}.xml"
				class="pager">
				<xsl:value-of select="./@breadcrumbName" />
			</a>
			<xsl:if test="count(child::node()) &gt; 0">
				<ul>
					<xsl:apply-templates select="child::node()" mode="list"/>
				</ul>
			</xsl:if>
		</li>
	</xsl:template>
	
	
	
	
	
	<!-- MODE SELECT -->
	<xsl:template match="item" mode="select">
		<xsl:choose>
			<xsl:when test="./@isdirectory = 0">
				<li class="file inactive">
					<label>
						<xsl:value-of select="./@breadcrumbName" />
						<input type="radio" name="linkSelector" value="{@fullpath}" />
					</label>
				</li>
			</xsl:when>
			
			<xsl:otherwise>
				<li class="folder inactive">
					<label>
						<xsl:value-of select="./@breadcrumbName" />
						<input type="radio" name="linkSelector" value="{@fullpath}" />
					</label>
					<xsl:apply-templates select="child::node()" mode="select"/>
				</li>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template match="list" mode="select">
		<xsl:if test="count(child::node()) &gt; 0">
			<ul>
				<xsl:apply-templates select="child::node()" mode="select"/>
			</ul>
		</xsl:if>
	</xsl:template>
</xsl:stylesheet>
